//
//  IntentionTableViewCell.m
//  mcosApp
//
//  Created by YaSha_Tom on 2018/12/13.
//  Copyright © 2018年 YaSha-Tom. All rights reserved.
//

#import "IntentionTableViewCell.h"
@interface IntentionTableViewCell()
@property (nonatomic,strong)UILabel *userNameLabel;
@property (nonatomic,strong)UILabel *startTimeLabel;
@property (nonatomic,strong)UIImageView *placeImage;
@property (nonatomic,strong)UILabel *placeLabel;
@property (nonatomic,strong)UILabel *detailPlaceLabel;
@property (nonatomic,strong)UILabel *intentionProgressLabel;
@end

@implementation IntentionTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initUI];
    }
    return self;
}
- (void)initUI {
    
    //用户图片
    UIImageView *titImage = [[UIImageView alloc] init];
    [titImage setImage:[UIImage imageNamed:@"yixiang"]];
    [self addSubview:titImage];
    [titImage mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.mas_top).offset(15);
        make.left.mas_equalTo(self.mas_left).offset(18);
        make.size.mas_equalTo(CGSizeMake(35*kWidthScale, 35*kHeightScale));
    }];
    
    self.userNameLabel = [[UILabel alloc]init];
    self.userNameLabel.textColor = [UIColor blackColor];
    self.userNameLabel.font = [UIFont systemFontOfSize:17.0];
    [self addSubview:self.userNameLabel];
    [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.mas_top).offset(25*kHeightScale);
        make.left.mas_equalTo(titImage.mas_right).offset(8);
        make.size.mas_equalTo(CGSizeMake(100*kWidthScale, 15*kHeightScale));
    }];
    
    //设置开工时间
    self.startTimeLabel = [[UILabel alloc] init];
    self.startTimeLabel.textColor = [UIColor grayColor];
    self.startTimeLabel.font = [UIFont systemFontOfSize:11.0];
    self.startTimeLabel.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.startTimeLabel];
    
    [self.startTimeLabel mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.mas_top).offset(22*kHeightScale);
        make.left.mas_equalTo(self.userNameLabel.mas_right).offset(10);
        make.right.mas_equalTo(self.mas_right).offset(-15);
        make.height.mas_equalTo(10);
    }];
    
    //设置地点图片
    self.placeImage = [[UIImageView alloc] init];
    [self.placeImage setImage:[UIImage imageNamed:@"placeIcon"]];
    [self addSubview: self.placeImage];
    [self.placeImage mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.userNameLabel.mas_bottom).offset(25*kHeightScale);
        make.left.mas_equalTo(self.mas_left).offset(22);
        make.size.mas_equalTo(CGSizeMake(9*kWidthScale, 13*kHeightScale));
    }];
    
    // 设置地点
    self.placeLabel = [[UILabel alloc] init];
    self.placeLabel.backgroundColor = [UIColor clearColor];
    self.placeLabel.textColor = [UIColor grayColor];
    self.placeLabel.font = [UIFont systemFontOfSize:14.0];
    self.placeLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.placeLabel];
    
    [self.placeLabel mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.userNameLabel.mas_bottom).offset(25*kHeightScale);
        make.left.mas_equalTo(self.placeImage.mas_right).offset(8);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-150*kWidthScale, 14*kHeightScale));
        
    }];
    //详细地址
    self.detailPlaceLabel = [[UILabel alloc] init];
    self.detailPlaceLabel.backgroundColor = [UIColor clearColor];
    self.detailPlaceLabel.textColor = [UIColor grayColor];
    self.detailPlaceLabel.font = [UIFont systemFontOfSize:16.0];
    self.detailPlaceLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.detailPlaceLabel];
    [self.detailPlaceLabel mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.placeLabel.mas_bottom).offset(3);
        make.left.mas_equalTo(self.placeImage.mas_right).offset(8);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-150*kWidthScale,14*kHeightScale));
        
    }];
    
    //项目进度设置
    self.intentionProgressLabel = [[UILabel alloc] init];
    self.intentionProgressLabel.textColor = [UIColor grayColor];
    self.intentionProgressLabel.font = [UIFont systemFontOfSize:15.0];
    self.intentionProgressLabel.textAlignment = NSTextAlignmentCenter;
    self.intentionProgressLabel.backgroundColor = [UIColor clearColor];
    [self addSubview:self.intentionProgressLabel];
    [self.intentionProgressLabel mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.mas_equalTo(self.placeLabel.mas_top).offset(1);
        make.left.mas_equalTo(self.placeLabel.mas_right).offset(3);
        make.size.mas_equalTo(CGSizeMake(100*kWidthScale, 17*kHeightScale));
    }];
    
}
- (void)setIntentionListData:(IntentionListModel *)cellModel {
    self.userNameLabel.text = cellModel.name;
    self.startTimeLabel.text = cellModel.createTime;
    self.placeLabel.text = [NSString stringWithFormat:@"%@%@%@",cellModel.province,cellModel.city,cellModel.area];
    self.detailPlaceLabel.text = [NSString stringWithFormat:@"%@%@%@",cellModel.buildName,cellModel.buildGroupName,cellModel.address] ;
    self.intentionProgressLabel.text = cellModel.statusName;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
